package com.starlink.controller.wechat;

import com.github.pagehelper.PageInfo;
import com.starlink.common.WebResponse;
import com.starlink.common.annotation.WebAccess;
import com.starlink.model.request.MallIntegrationRequest;
import com.starlink.model.request.save.MallPeripherySaveRequest;
import com.starlink.model.vo.MallIntegrationVO;
import com.starlink.model.vo.MallPeripheryVO;
import com.starlink.service.MallIntegrationService;
import com.starlink.service.MallPeripheryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: zhouyuhang01
 * @Date: 2024/4/11 09:54
 * @Description: WechatMallPeripheryController
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/wechat/integration")
@Api(value = "【小程序端】商城积分兑换模块", tags = {"【小程序端】商城积分兑换模块"})
public class WechatMallIntegrationController {

    @Autowired
    private MallIntegrationService integrationService;

    @WebAccess(login = true)
    @ApiOperation("分页查询")
    @PostMapping("/pageList")
    public WebResponse<PageInfo<List<MallIntegrationVO>>> pageList(@SortDefault(sort = {"t1.create_time"}, direction = Sort.Direction.DESC) Pageable pageable,
                                                                   @RequestBody MallIntegrationRequest request) {
        return WebResponse.build(integrationService.pageList(pageable,request));
    }

    @WebAccess(login = true)
    @ApiOperation(value = "查询积分商品详情", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/get/{id}")
    public WebResponse<MallIntegrationVO> getByKey(@PathVariable("id") long id) {
        return WebResponse.build(integrationService.getByKey(id));
    }
}
